<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> 
<head>
<title>ISerializable Sample</title>
<link rel="stylesheet" type="text/css" href="../../../../docs/rotor.css">
</head>

<body>		


<h1> ISerializable Sample</h1>


<h2>Sample Overview</h2>


<p>This sample illustrates how to use the <b>ISerializable</b> interface and XML 
serialization to 
customize the serialization of your own objects. This sample serializes objects 
that store reflection information from the mscorlib assembly namespace. Each object contains a 
property as the name of the item and a list of children as per the class in the 
mscorlib assembly. To demonstrate the customization possible with <b>
ISerializable</b>, the string &quot;(SAVED)&quot; is appended to the namespace name to indicate that 
the values are not live. When the data is read back in, this tag could be 
modified or removed.</p>


<p>The sample  starts by using reflection to create a TreeNode object that 
containing a list of TreeNode objects that represent types in the mscorlib 
assembly. This object is then  serialized to disk. The user is 
then be prompted to continue  deserializing the object from the XML file on 
disk.&nbsp; The sample  then outputs the results of the deserialized object 
to the console.</p>


<p>The sample  generates a file named objectgraph.xml. This file 
contains the XML-serialized representation of the TreeNode object.</p>


<h2>Sample Source and Build Output Locations</h2>


<p>The sample source is found in sscli20\samples\howto\serialization\iserializable.&nbsp; </p>


<p>The source file is:</p>


<ul class="none">
  <li><a href="iserializable.cs">iserializable.cs</a></li>
</ul>


<p>The build output location is %_NTTREE%\samples\serialization.&nbsp; The 
output file is an executable assembly named iserializable.exe.</p>


<h2>Building the Sample</h2>


<p>All samples are built from the buildall script.&nbsp;  </p>


<p>You can also build all the 
samples by switching to the root of the sample directory, sscli20\samples, and typing 
<code>build -c</code>.</p>


<p>You can build this specific sample  by switching to the sample directory and typing 
<code>build -c</code>.</p>


<h2>Running the Sample</h2>


<p>These steps require that the Shared Source CLI (SSCLI) be already built and 
functional.</p>


<ol>
  <li>Run env.bat. </li>
  <li>Switch to the %_NTTREE%\samples\serialization directory.</li>
  <li>Type the following command:<blockquote>


<p>clix&nbsp; iserializable.exe</p>


  </blockquote>


  </li>
</ol>


<hr>


<p><i>Copyright (c) 2006 Microsoft Corporation. All rights reserved.</i></p>
</body> 
</html>